<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: generator.php 39 2007-09-02 12:49:05Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(APP_DIR. '/Lang.php');
echo $this->render('header.php');

$this->single_object = Inflector::singularize($this->meta['name']);
$this->controller_name = str_replace('_', '', $this->single_object);
$this->plural_object = $this->meta['name'];
$this->class_object = Inflector::classify($this->meta['name']);
?>
<style type="text/css">
.CurInfo h2.Title {
display:none;
}
</style>
<form action="<?php echo $this->base_url;?>/generator/scripts/" method="post" enctype="multipart/form-data" name="frm<?php echo $this->class_object ; ?>Generator" id="frm<?php echo $this->class_object ; ?>Generator">
<script language="JavaScript" type="text/javascript" src="<?php echo $this->wwwroot;?>/js/taobao_tabs.js"></script>
<div id="InfoSelectorTarget"></div>
<div id="ControllerCode">
<h2 class="Title">控制器代码<span></span></h2>
文件名：<input type="text" name="fields[controller][filename]" value="<?php echo $this->class_object;?>Controller.php" size="50" /><br />
	<textarea name="fields[controller][content]" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/controller.php")), $nl2br = false);
	?>	</textarea>
</div>
<div id="scriptsListCode">
	<h2 class="Title">列表模板<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	文件名：<input type="text" name="fields[scripts][list][filename]" value="<?php echo $this->controller_name;?>_list.php" size="50" /><br />
	<textarea name="fields[scripts][list][content]" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/scripts/list.php")), $nl2br = false);
	?>	</textarea>
</div>
<div id="scriptsViewCode">
	<h2 class="Title">详细模板<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	文件名：<input type="text" name="fields[scripts][view][filename]" value="<?php echo $this->controller_name;?>_view.php" size="50" /><br />
	<textarea name="fields[scripts][view][content]"  wrap="physical" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/scripts/view.php")), $nl2br = false);
	?></textarea>
</div>
<div id="scriptsAddCode">
	<h2 class="Title">新增模板<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	文件名：<input type="text" name="fields[scripts][add][filename]" value="<?php echo $this->controller_name;?>_add.php" size="50" /><br />
	<textarea name="fields[scripts][add][content]" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/scripts/add.php")), $nl2br = false);
	?></textarea>
	</div>
<div id="scriptsEditCode">
	<h2 class="Title">编辑模板<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	文件名：<input type="text" name="fields[scripts][edit][filename]" value="<?php echo $this->controller_name;?>_edit.php" size="50" /><br />
	<textarea name="fields[scripts][edit][content]" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/scripts/edit.php")), $nl2br = false);
	?></textarea>
</div>
<div id="scriptsMetaCode">
	<h2 class="Title">语言模板<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	文件名：<input type="text" name="fields[scripts][meta][filename]" value="_meta_<?php echo $this->controller_name;?>.php" size="50" /><br />
	<textarea name="fields[scripts][meta][content]" rows="100" cols="100" onfocus="this.select();"><?php
	echo $this->textFormat(htmlspecialchars_decode($this->render("generator/scripts/meta.php")), $nl2br = false);
	?></textarea>
	</div>
	<div id="GeneratorOptions">
	<h2 class="Title">选项<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	<div class="tips">
	模板文件均保存在<?php echo $this->scripts_path;?><br />
	控制器文件均保存在<?php echo $this->controller_path;?>
</div>
	<label>
<input type="checkbox" name="fields[options][overwrite]" id="fields_options_overwrite" value="1"/>如果要覆盖已存在的文件请勾选此项。</label>

	<input type="submit" value="提交" />
	</div>
	<div id="GeneratorReference">
	<h2 class="Title">模型源代码<span><a href="#"><img src="<?php echo $this->wwwroot; ?>/images/gotop.gif" alt="至顶端" height="16" width="16"></a></span></h2>
	<?php
	echo $this->textFormat(var_export($this->meta, true));
	?>
	</div>
<script language="JavaScript" type="text/javascript">
	var TabNames = [];
	var TabIds =[];
	convertTabMap({
		'ControllerCode':'控制器',
		'scriptsListCode':'列表',
		'scriptsViewCode':'详情',
		'scriptsAddCode':'新增',
		'scriptsEditCode':'编辑',
		'scriptsMetaCode':'字段',
		'GeneratorOptions':'选项',
		'GeneratorReference':'参考'
	});
	initInfoSelector();
</script>
</form>
<?php
echo $this->render('footer.php');
?>